package com.itheima.homework02;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(6666);
        while (true) {
            Socket socket = ss.accept();
            System.out.println("客户端" + socket.getRemoteSocketAddress());
            DataInputStream dis = new DataInputStream(socket.getInputStream());
            String data = dis.readUTF();
            System.out.println("客户端发送的数据：" + data);
            //向客户端反馈信息
            DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
            dos.writeUTF("不约，没空，我要学习Java，等我毕业找到工作，再约！！");
            socket.shutdownOutput();

            socket.close();
        }
    }
}
